/*
 * @Author: chen haoxuan
 * @Date: 2021-05-22 22:20:03
 * @LastEditTime: 2021-05-23 22:51:48
 */
// 4.6 重载单目运算符
/*
    单目运算符只有一个操作数
    下面为自增运算符 ++ 的重载
*/
#include <iostream>
using namespace std;
class Time
{
public:
    Time()
    {
        minute = 0;
        sec = 0;
    }
    Time(int m, int s) : minute(m), sec(s){};
    Time operator++();
    void display() { cout << minute << ":" << sec << endl; }

private:
    int minute;
    int sec;
};
Time Time::operator++() // 前置自增
{
    if (++sec >= 60)
    {
        sec -= 60;
        ++minute;
    }
    return *this; // 返回当前对象值
}
int main()
{
    Time time1(34, 0);
    for (int i = 0; i < 60; i++)
    {
        ++time1;
        time1.display();
    }
    system("pause");
    return 0;
}